home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 11 / FM Towns Free Software Collection 11.iso / t_os / tool / artemis1 / src / pltbak.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-11  |  5.1 KB  |  216 lines

  1. /*
  2.     plt.c
  3. */
  4.  
  5. #include <stdio.h>
  6. #include <egb.h>
  7.  
  8. #include "ge.h"
  9.  
  10. /*--------------------------------------------------------*/
  11. /*               パレットリストの描画・消去                */
  12. /*--------------------------------------------------------*/
  13.  
  14. static    int        pltlist_preDispX,pltlist_preDispY;
  15. static    int        pltlist_x,pltlist_y;
  16. static    bool    pltlist_dsp = NO;
  17.  
  18. void makeupPltList()
  19. {
  20.     msgout("makeupPltList begin");
  21.  
  22.     int i,j,px,py;
  23.     gwrtpage(1);
  24.     px = dispX + pltlist_x / zoomX;
  25.     py = dispY + pltlist_y / zoomY;
  26.     for (i=0; i<4; i++) {
  27.         for (j=0; j<4; j++) {
  28.             grboxfill(px+(j*16)/zoomX,py+(i*16)/zoomY,
  29.                       16/zoomX,16/zoomY,plt[i*4+j],DrawNORMAL);
  30.         }
  31.     }
  32.     gwrtpage(0);
  33.  
  34.     msgout("makeupPltList end");
  35. }
  36.  
  37. static char pltListScrBuf[80*80*2];
  38.  
  39. void drawPltList(int x,int y)
  40. {
  41.     msgout("drawPltList begin");
  42.  
  43.     int i,j,px,py;
  44.     pltlist_dsp = YES;
  45.     pltlist_preDispX = dispX;
  46.     pltlist_preDispY = dispY;
  47.     if (x != -1)
  48.         pltlist_x = x;
  49.     if (y != -1)
  50.         pltlist_y = y;
  51.     gwrtpage(1);
  52.     px = dispX + pltlist_x / zoomX;
  53.     py = dispY + pltlist_y / zoomY;
  54.     grp_getblk(px,py,(16*4)/zoomX,(16*4)/zoomY,pltListScrBuf);
  55.     gwrtpage(0);
  56.     makeupPltList();
  57.  
  58.     msgout("drawPltList end");
  59. }
  60.  
  61. void erasePltList()
  62. {
  63.     msgout("erasePltList begin");
  64.  
  65.     int px,py;
  66.     pltlist_dsp = NO;
  67.     gwrtpage(1);
  68.     px = pltlist_preDispX + pltlist_x / zoomX;
  69.     py = pltlist_preDispY + pltlist_y / zoomY;
  70.     grp_putblk(pltListScrBuf,px,py);
  71.     gwrtpage(0);
  72.  
  73.     msgout("erasePltList end");
  74. }
  75.  
  76. void drawPltList_init(int x, int y)
  77. {
  78.     int i,j;
  79.     for (i=0; i<4; i++) {
  80.         for (j=0; j<4; j++) {
  81.             grboxfill(x-1+j*16,y-1+i*16,17,17,Transparent,DrawNORMAL);
  82.             grboxline(x-1+j*16,y-1+i*16,17,17,Black,DrawNORMAL);
  83.         }
  84.     }
  85. }
  86.  
  87. bool getPltList_disp()
  88. {
  89.     return pltlist_dsp;
  90. }
  91.  
  92. /*--------------------------------------------------------*/
  93. /*                  RGB バーの描画・更新                   */
  94. /*--------------------------------------------------------*/
  95.  
  96. static    int        rgb_x,rgb_y;
  97.  
  98. #define    _rgbBarLen    (scrmode == 10 ? 31 : 30)
  99.  
  100. void makeupRgbBar()
  101. {
  102.     msgout("makeupRgbBar begin");
  103.     int a,i,t,rgb[3];  static int RGBcol[]={White,White,White};
  104.     if (scrmode == 10) {    // 3万色モード
  105.         t = plt[pltnum];
  106.         rgb[0]=getR(t); rgb[1]=getG(t); rgb[2]=getB(t);
  107.     } else {                // 16色モード
  108.         char pal_[4+8*16];
  109.         EGB_getPalette(1,pal_);
  110.         rgb[0] = (pal_[4+8*pltnum+4+1] >> 4) & 0xf;
  111.         rgb[1] = (pal_[4+8*pltnum+4+2] >> 4) & 0xf;
  112.         rgb[2] = (pal_[4+8*pltnum+4  ] >> 4) & 0xf;
  113.         // t = grp_getplt(pltnum);
  114.         // rgb[0]=((t>>16)&0xff)*2; rgb[1]=((t>>8)&0xff)*2; rgb[2]=(t&0xff)*2;
  115.     }
  116.     for (i=0; i<3; i++) {
  117.         int    barlen;
  118.         a = rgb[i];
  119.         barlen = (scrmode == 10 ? a : a*2);
  120.         grboxfill(rgb_x+i*14,rgb_y,11,_rgbBarLen,Black,DrawNORMAL);
  121.         if (a!=0)
  122.             grboxfill(rgb_x+i*14,rgb_y+(_rgbBarLen-barlen),11,barlen,RGBcol[i],DrawNORMAL);
  123.         putpict(rgb_x+i*14,rgb_y+47,(a<10 ? Pnonum : Pzero+a/10));
  124.         putpict(rgb_x+i*14+6,rgb_y+47,(Pzero+a%10));
  125.     }
  126.     msgout("makeupRgbBar end");
  127. }
  128.  
  129. void drawRgbBar(int x, int y)
  130.     {
  131.     msgout("drawRgbBar begin");
  132.     int i;
  133.     rgb_x = x;
  134.     rgb_y = y;
  135.     for (i=0; i<3; i++) {
  136.         grboxfill(x+i*14,y,11,_rgbBarLen,Black,DrawNORMAL);
  137.         putpict(x+i*14,y+32,Prgb_updown);
  138.         putpict(x+i*14,y+54,Prgb_r+i);
  139.         }
  140.     makeupRgbBar();
  141.     msgout("drawRgbBar end");
  142.     }
  143.  
  144. /*--------------------------------------------------------*/
  145. /*                     RGB 要素の増減                     */
  146. /*--------------------------------------------------------*/
  147.  
  148. void touchRgbBar(int ax, int ay, int btn)
  149. {
  150.     msgout("touchRgbBar begin");
  151.     int rgb[3],t,rgbx;
  152.     rgbx = ax / 14;
  153.     if ((ax % 14) > 11)
  154.         return;
  155.     if (scrmode == 10) {
  156.         t = plt[pltnum];
  157.         rgb[0] = getR(t);
  158.         rgb[1] = getG(t);
  159.         rgb[2] = getB(t);
  160.         if (0<=ay && ay<=31)
  161.             rgb[rgbx]= 31-ay;
  162.         else if (32<=ay && ay<32+7) {
  163.             if (btn==OFFON && rgb[rgbx]<31)
  164.                 rgb[rgbx]++;
  165.         } else if (32+7<=ay && ay<32+14) {
  166.             if (btn==OFFON && rgb[rgbx]>0)
  167.                 rgb[rgbx]--;
  168.         }
  169.         plt[pltnum] = GRB(rgb[1],rgb[0],rgb[2]);
  170.     } else {
  171.         gwrtpage(1);
  172.         {
  173.             char pal_[4+8*16];
  174.             EGB_getPalette(1,pal_);
  175.             rgb[0] = (pal_[4+8*pltnum+4+1] >> 4) & 0xf;
  176.             rgb[1] = (pal_[4+8*pltnum+4+2] >> 4) & 0xf;
  177.             rgb[2] = (pal_[4+8*pltnum+4  ] >> 4) & 0xf;
  178.             // t = grp_getplt(pltnum);
  179.             // rgb[0]=((t>>16)&0xff)*2; rgb[1]=((t>>8)&0xff)*2; rgb[2]=(t&0xff)*2;
  180.         }
  181.         gwrtpage(0);
  182.  
  183.         // t = grp_getplt(pltnum);
  184.         // rgb[0] = (t >> 16) & 0xff;
  185.         // rgb[1] = (t >>  8) & 0xff;
  186.         // rgb[2] =  t        & 0xff;
  187.         if (0<=ay && ay<=30)
  188.             rgb[rgbx]= (30-ay)/2;
  189.         else if (32<=ay && ay<32+7) {
  190.             if (btn==OFFON && rgb[rgbx]<15)
  191.                 rgb[rgbx]++;
  192.         } else if (32+7<=ay && ay<32+14) {
  193.             if (btn==OFFON && rgb[rgbx]>0)
  194.                 rgb[rgbx]--;
  195.         }
  196.         gwrtpage(1);
  197.         {
  198.             char pal_[4+8*16];
  199.             DWORD(pal_ + 0) = 1;
  200.             DWORD(pal_ + 4) = pltnum;
  201.             BYTE (pal_ + 8) = rgb[2] << 4;
  202.             BYTE (pal_ + 9) = rgb[0] << 4;
  203.             BYTE (pal_ +10) = rgb[1] << 4;
  204.             BYTE (pal_ +11) = 0;
  205.             EGB_palette(_egbwork,0,pal_);
  206.         }
  207.         gwrtpage(0);
  208.         // grp_setplt(pltnum, (rgb[0]<<20)|(rgb[1]<<12)|(rgb[2]<<4));
  209.     }
  210.     makeupPltList();
  211.     makeupRgbBar();
  212.     msgout("touchRgbBar end");
  213. }
  214.  
  215. /* end of plt.c */
  216.